package org.ccunix.eshop.utils;

import com.mchange.v2.c3p0.ComboPooledDataSource;

import java.sql.Connection;
import java.sql.SQLException;


public class DataSource {
    //数据库连接池对象 装了n个连接对象Connection
    private static ComboPooledDataSource dataSource= new ComboPooledDataSource();
    /**
     *  获取Connection连接
     * @return
     */
    public static Connection getConnection(){
        Connection conn = null;
        try {
            conn = dataSource.getConnection();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }

    public static void main(String[] args) {
        for(int i=0;i<10;i++){
            System.out.println(getConnection());
        }
    }
}

